<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@ page import="java.util.*"%>
<%@ page import="database.*"%>
<%@ page import="forum.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Forums</title>
</head>
<body>
	<h2>Forums list</h2>
	<table border="1">
		<tbody>
			<%
				List<Forum> forumsList = (ArrayList<Forum>) request.getAttribute("forums");
				boolean isModerator = (Boolean) request.getAttribute("isModerator");

				for (Forum f : forumsList) {
					out.println("<tr>");
					out.println("<td>" + f.getSubject() + "</td>");

					out.println("<td><a href=\"viewForums?do=show&id=" + f.getID() + "\">Show</a></td>");
					if (isModerator)
						out.println("<td><a href=\"viewForums?do=delete&id=" + f.getID() + "\">Delete</a></td>");
					out.println("</tr>");
				}
			%>
		</tbody>
	</table>
	<br>
	<%
	if (isModerator)
		out.println("<a href=viewForums?do=add>Add a new forum</a>");
	%>
	<br>	
	<a href="viewFriends">Show friends</a>
	<br>
	<a href="logout">logout</a>
	
</body>
</html>